<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+


class UserView_form extends AppView
{
	
	var $tmpl = 'form.html';
	var $account_view = false;

	
	function execute(&$obj, &$manager) {
		
		$this->addMsg('user_msg.ini');
		
		$tpl = &new tplTemplatez($this->template_dir . $this->tmpl);
		$tpl->tplAssign('error_msg', AppMsg::errorBox($obj->errors));
		
		// priv select
		if($obj->is_admin) {
			
			$priv_lang = AppMsg::getMsgs('privileges_msg.ini');
			
			$priv_data = $manager->getAllPriv();
			foreach($priv_data as $k => $v) {
				$priv_data[$k] = $priv_lang[$k]['name'];
			}
			
			$select = new FormSelect();
			$select->setSelectWidth(250);
			$select->setMultiple(5, false);
			$select->setSelectName('priv');
			$select->setRange($priv_data);
			
			$tpl->tplSetNeededGlobal('priv_box');
			$tpl->tplAssign('priv_select', $select->select($obj->getPriv()));
			
			
			foreach($priv_lang as $k => $v) {
				$v['description'] = nl2br($v['description']);
				$tpl->tplParse($v, 'priv_description');
			}
		}
		
		
		if($this->controller->getAction() == 'update') {
			$tpl->tplSetNeeded('/not_change_pass');
		}
		
		
		$val = ($_POST) ? $_POST['not_change_pass'] : 1;
		$tpl->tplAssign('pass_change_checked', $this->getChecked($val));
		
		if(!$this->account_view) {
			$tpl->tplSetNeededGlobal('account');
		}
		
		
		$tpl->tplAssign($this->setCommonFormVars($obj));
		$tpl->tplAssign($this->setStatusFormVars($obj->get('active')));
		$tpl->tplAssign($obj->get());
		$tpl->tplAssign($this->msg);
		
		$tpl->tplParse();
		return $tpl->tplPrint(1);
	}
}
?>